import {onMounted, ref} from "vue";
import service from "../../service/service";
import {useRoute, useRouter} from "vue-router";

export default function ArticleDetails() {
    let content = ref('')
    const router = useRouter()
    let loading = ref(false)
    const route = useRoute()
    let title = ref('')
    let articleInfo = ref({})
    onMounted(() => {
        loading.value = true
        // 请求文章内容
        let data = {id:route.query.id}
        service.getArticleDetails(data).then(r => {
            content.value = r.data['msg']['Content']
            title.value = r.data['msg']['Title']
            articleInfo.value.sort = r.data['msg']['Class']
            articleInfo.value.author = r.data['msg']['Author']
            loading.value = false
        })
    })
    return {
        loading,
        content,
        title,
        articleInfo
    }
}